package com.bdjk.bdmw.InfoGath.communication.server.tcp.socket;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

import org.apache.log4j.Logger;

/**
 * @author hy
 *
 */
public class ServerInputThread extends Thread {
	private static final Logger logger = Logger.getLogger(ServerInputThread.class);

	private Socket socket;

	public ServerInputThread(Socket socket) {
		super();
		this.socket = socket;
	}

	@Override
	public void run() {
		try {
			// 获得输入流
			InputStream is = socket.getInputStream();
//			byte[] buffer = new byte[1024];
//
//			int length = is.read(buffer);
//
//			String str = new String(buffer, 0, length);
//
//			logger.info("********" + str + "********");
			while(true){
				byte[] buffer = new byte[1024];

				int length = is.read(buffer);

				String str = new String(buffer, 0, length);
				

				logger.info("--------" + str + "---------");
				System.out.println("Server--------" + str + "---------");
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}